package com.xds.gulimall.order.controller;

import com.xds.gulimall.order.entity.OrderEntity;
import com.xds.gulimall.order.entity.OrderReturnReasonEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.UUID;

/**
 * @author : baixu
 * @date : 19:10 2021/12/23
 */
@Controller
public class RabbitController {
    @Autowired
    RabbitTemplate rabbitTemplate;
    @GetMapping("/sendMq")
    public String sendMq(@RequestParam(value = "num",defaultValue = "10")Integer num){
        for (int i = 0; i < num; i++) {

                OrderReturnReasonEntity entity = new OrderReturnReasonEntity();
                entity.setId(2L);
                entity.setCreateTime(new Date());
                entity.setName("肖大帅");
                rabbitTemplate.convertAndSend("hello-java-directExchange","hello.java",entity);


        }
        return "ok";
    }


}
